package com.example.arithmeticleetcode.leetcode.September;

import java.util.HashSet;
import java.util.Set;

/**
 * @program: arithmetic-leetcode
 * @description:
 * @author: FangZhen
 * @create: 2020-09-23 10:24
 **/
public class Demo17 {

    public static void main(String[] args) {
        String s1 = "ababccc";
        System.out.println(maxUniqueSplit(s1));
        String s2 = "abcdefg";
        System.out.println(s2.substring(1));
    }

    public static int maxUniqueSplit(String s) {
        Set<String> set = new HashSet<>();
        for (int i = 0, len = s.length(); i < len; i++) {
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.append(s.charAt(i));
            while (set.contains(stringBuilder.toString())) {
                i++;
                stringBuilder.append(s.charAt(i));
            }
            set.add(stringBuilder.toString());
        }
        return set.size();
    }
}
